﻿Imports DAO
Imports DTO
Public Class TacGiaBUS
    Dim dt As New DataTable

    Public Function LayTacGia() As DataTable
        Dim tg As New TacGiaDAO
        dt = tg.LayDanhSachTacGia()
        Return dt
    End Function

    Public Sub ThemTacGia(ByVal tg As TacGiaDTO)
        Dim tg1 As New TacGiaBUS
        Dim dt As New DataTable
        dt = tg1.LayTacGia()
        For i = 0 To dt.Rows.Count - 1
            Dim dr As DataRow = dt.Rows(i)
            If LCase(dr.Item("TenTacGia").ToString.Trim) = LCase(tg.LayTenTacGia.Trim) Then
                Throw New Exception("Tác giả " & tg.LayTenTacGia & " đã tồn tại")
            End If
        Next
        Dim tacgia As New TacGiaDAO
        tacgia.ThemTacGiaMoi(tg)
    End Sub

    'Public Sub XoaTacGia(ByVal tacgia As TacGiaDTO)
    '    Dim tg As New TacGiaDAO
    '    tg.XoaTacGia(tacgia)
    'End Sub

    Public Function LayTenTacGia(ByVal tg As TacGiaDTO) As DataTable
        Dim dt As New DataTable

        Return dt
    End Function
End Class
